<template>
    <Teleport to="body" v-if="dialogData.visible">
        <div class="preview ">
            <div class="mobile-container">
                <iframe :src="'#/mobile-preview?id='+dialogData.item.id" frameborder="0" style="width:100%;height:100%"></iframe>
            </div>
            <div class="close-btn" @click="dialogData.visible = false">
                <el-icon :size="40">
                    <CircleClose/>
                </el-icon>
            </div>
        </div>
    </Teleport>
</template>


<script setup>

import { nextTick, reactive, ref, useTemplateRef } from 'vue'

const emits = defineEmits(['update'])
defineExpose({ openDialog })

const dialogData = reactive({
    visible: false,
    type: '',
    item: {}
})

/**
 * 打开弹框
 * @param type
 * @param item
 */
function openDialog (item) {
    dialogData.visible = true
    dialogData.item = item
}


</script>

<style lang="less" scoped>
.preview {
    width: 100vw;
    height: 100vh;
    position: fixed;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: flex;
    justify-content: center;
    align-items: center;
    left: 0;
    top: 0;
    .mobile-container {
        width: 375px;
        height: 800px;
        padding: 60px 30px 40px;
        overflow: hidden;
        box-sizing: border-box;
        background: #fff;
        background: url('@/assets/image/mobile.png') no-repeat center center / 100% 100%;

        // 隐藏滚动条
        ::-webkit-scrollbar {
            display: none;
        }
    }
    .close-btn {
        position: absolute;
        left: calc(50% + 365px / 2 + 10px);
        top: calc(50% - 800px / 2 + 10px);
        cursor: pointer;
        color: #fff;

    }
}
</style>
